home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-03-31 | 6.0 KB | 61 lines | [TEXT/MPS ] |
- /*****************************************************************************
-
- mac_undo.c: Copyright (c) Kevin Hammond 1993. All rights reserved.
-
- Utility Functions.
-
- *****************************************************************************/
-
-
- #include "mac.h"
-
- #pragma segment Utils
-
- extern pascal Boolean AutoScroll();
-
- extern jmp_buf catch_error;
- extern CursHandle watchcurs, gccurs; /* Watch and GC cursors */
- extern CCrsrHandle gccursc; /* Colour version of GC cursor */
- extern Boolean CCAvailable; /* Are colour cursors available */
- extern Boolean inForeground; /* Are we in the background? */
-
- /*
- See if a trap is available.
- Non-available traps all have the same unique address.
- */
-
- #define Unimplemented 0xA89F /* Unimplemented trap */
-
-
- Boolean TrapAvailable (trap,type)
- short trap, type;
- {
- return(NGetTrapAddress(trap, type) != GetTrapAddress(Unimplemented));
- }
-
- /*
- NB: A Macintosh TN says TextEdit may fail if the size of the
- viewrect (?destrect?) is greater than 32767 pixels in area.
- BEWARE: I do not check this!
- */
-
- /* Defined to make TE handling a little cleaner -- HSL */
- #define TE_RECT_INSET 4
- #define TE_RECT_WIDTH 1024
-
- void CalculateTERects(Rect *theViewR, Rect *theDestR, short theLineHeight,int fittovr)
- /* Calculates the view and destination rectangles for a TE */
- /* Assumes that the current port is set to the TE's port */
- {
- Rect pr = qd.thePort->portRect;
- short roundedViewHeight;
- short te_rect_width = qd.screenBits.bounds.right > TE_RECT_WIDTH?
- qd.screenBits.bounds.right: TE_RECT_WIDTH;
-
- // if((pr.right - (SCROLLBARWIDTH - 1))*(pr.bottom - (SCROLLBARWIDTH - 1)) > 32767)
- // AbortError("Internal","View Rectangle too large for TextEdit to handle");
-
- SetRect(theViewR, 0, 0, pr.right - (SCROLLBARWIDTH - 1), pr.bottom - (SCROLLBARWIDTH - 1));
- InsetRect(theViewR, TE_RECT_INSET, TE_RECT_INSET);
- roundedViewHeight = ((theViewR->bottom - theViewR->top) / theLineHeight) * theLineHeight;
- theViewR->bottom = theViewR->top